home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / basic / vidbasic.zip / VEGAMONO.ASM < prev    next >
Assembly Source File  |  1990-11-29  |  6KB  |  180 lines

  1. ;«RM82»«TS8,16,24,32,40,48,56,64»
  2. ; Updated 11/20/90
  3.  
  4. ;============================================================================
  5. ;   Copyright (C) Copr. 1990 by Sidney J. Kelly
  6. ;           All Rights Reserved.
  7. ;           Sidney J. Kelly
  8. ;           150 Woodhaven Drive
  9. ;           Pittsburgh, PA 15228
  10. ;           home phone 412-561-0950 (7pm to 9:30pm EST)
  11. ;============================================================================
  12.  
  13. ;============================================================================
  14. ; DECLARE EGAMONO (BYVAL Mode%)
  15. ; CALL EGAMONO (Mode%)
  16. ; Purpose:
  17. ;    Forces VGA/EGA mono display to normal MONO attributes
  18. ;     This allows programmer to have the same attributes appear on a 
  19. ;    HERC, MONO, or EGA Mono Display
  20. ; Input:
  21. ;       Mode%  = 0 if want default mono attributes
  22. ;       Mode% <> 0 if want Herc type attributes
  23. ; Returns: Nothing
  24. ;
  25. ; Limitations:
  26. ;        For contrast, colors can only be used against White or Intense.
  27. ;        Primary colors appear as Black.
  28. ;        Only White or Intense can be contrasted against Black.
  29. ;        Blue and Intense Blue attributes are not underlined, unlike HERC/MONO
  30. ;        All intense colors appear as white.  
  31. ; Full control over VGA is not possible because of GRAY scaling and large 
  32. ; number of DAC/palette registers.  To get control over those two features would
  33. ; make the program much larger. 
  34. ; Tinkering required for mono MCGA, but who has one of those?
  35. ;============================================================================
  36.  
  37. DOSSEG
  38. .MODEL MEDIUM
  39.     PUBLIC    EGAMONO
  40. .CODE
  41. ; Store info in .CODE rather than DGROUP because DGROUP is so small
  42. ; while .CODE is very large in QBASIC
  43.  
  44. ; Resets EGA Palatte Table to defaults more like the MDA than CGA
  45. EVEN
  46. Herc_Table      db   0, 10h, 10h, 10h, 10h, 10h, 10h,  8
  47.         db 10h, 18h, 18h, 18h, 18h, 18h, 18h, 18h
  48.         db   0    ;this last is the border and should be 0
  49.  
  50. ; Resets EGA Palatte Table to normal EGA mono defaults
  51. Norm_Table      db     0,   8,   8,   8,   8,   8,   8,  8
  52.         db   10h, 18h, 18h, 18h, 18h, 18h, 18h, 18h
  53.         db   0    ;this last is the border and should be 0
  54.  
  55.  
  56. Status          db      0       ; allow us to keep track
  57.                 ; of prior calls
  58.                 ; Never called    = 0
  59.                 ; MONO EGA        = 2
  60.                 ; Everything else = 1
  61. EVEN
  62. EGAMONO    PROC    FAR
  63.     Push    BP              ; permit access to stack
  64.     Mov    BP,SP
  65.     Cmp     Status,0        ; have we done this before?
  66.     JE    VGATest        ; nope, so test display type
  67.     Cmp    Status,2    ; is it EGA MONO
  68.     JE    Mono1        ; yes so do it
  69.     Jmp     Finis           ; not a MONO EGA, so quit
  70.  
  71. VGATest:                        ; tests only for active display
  72.          Mov     AX,1A00h
  73.          Mov     BX,10h          ; Test for VGA adapter
  74.          Int     10h
  75.          Cmp     AL,1Ah          ; If VGA adapter exists, it returns AL=1Ah
  76.          Jne     EGATest         ; VGA does not exist so test for EGA
  77.     Cmp     BL,5            ; Else VGA exists, primary display info
  78.     Je      Mono            ; BL = 5 if have EGA mono as primary
  79.     Cmp    BL,7
  80.     Je    Mono        ; BL = 7 if have VGA mono as primary
  81.  
  82. OtherDsp:
  83.     Mov    Status,1    ; VEGA/EGA not active, report other mode & quit
  84.     Jmp    Short Finis     ; 
  85.  
  86. EGATest:
  87.     Mov     AX,1200h
  88.     Mov     BX,10h
  89.     Int     10h
  90.     Cmp     BL,10h          ; EGA changes BL from 10h
  91.     Je      OtherDsp        ; no EGA assume other
  92.     Mov     DX,BX           ; Save BX temporarily in DX
  93.     Xor     BX,BX        ; read BIOS ram
  94.     Mov     ES,BX           ; EGA active?, bit 3 of 0040:0087 set?
  95.     Test    Byte Ptr ES:[487h],1000b
  96.     JZ      EGA_active      ; if bit clear, then EGA is active
  97.     Jmp     Short OtherDsp  ; else if EGA not active (primary).
  98.                 ; report other display active and quit
  99. EGA_active:
  100.     Mov     BX,DX           ; get former value back from DX
  101.     Or      BH,BH           ; if BH = 1 then have MONO display
  102.  
  103.     JNZ     Mono            ; report EGA Mono display
  104.     Jmp     Short  OtherDsp ; else report other display active & quit
  105.  
  106. Mono:
  107.     Mov    Status,2    ; report have VGA/EGA mono
  108.  
  109. Mono1:
  110.     ;some unneeded code shows how to manage EGA
  111.     ;CLI                     ; must clear interrupts
  112.     ;Mov     DX,03BAh        ; reset attribute controller flip-flop
  113.     ;In      AL,DX           ; by reading toggle port
  114.     ;Mov     DX,03C0h        ; attribute controller address
  115.     ;Mov     AL,30h          ; set address of Mode Control w/o turning
  116.                   ; off display
  117.     ;Out     DX,AL           ; write address
  118.     ;Mov     AL,0110b        ; Turn blinking off, enable line characters
  119.                  ; assume display type is mono
  120.                  ; assume alpha mode
  121.     ;Out     DX,AL           ; send it out
  122.     ;STI                     ; turn on interrupts
  123.  
  124.     Mov     AX,CS           ; reload a default palette for EGA mono
  125.     Mov     ES,AX
  126.  
  127.     Assume  DS:Nothing, ES:@code   ; This required so OFFSET works
  128.                     ; when table in .CODE rather than
  129.                     ; in DGROUP
  130.  
  131.     Mov     BX,[BP+6]
  132.     Or      BX,BX            ; Is Mode% = 0
  133.     JZ      Norm_Pal         ; then load default EGA Mono Palette
  134.  
  135. Herc_Pal:                        ; else do Herc Palette
  136.  
  137.     Mov     DX, OFFSET Herc_Table
  138.     Mov     AX,1002h         ; reload Palette with table at ES:DX
  139.     Int     10h              ; table is 17 bytes long
  140.  
  141.                  ; turn on underlining
  142.     Xor     BX,BX            ; set BX to 0
  143.     Mov     ES,BX            ; set ES to 0
  144.  
  145.     Assume  ES:Nothing
  146.  
  147.     Mov     AH,ES:[0485h]    ; read character height
  148.     Dec     AH               ; reduce character height by 1
  149.     Mov     DX,03B4h         ; load CRTC port address for mono display
  150.     Mov     AL,14h           ; underline location address register
  151.     Out     DX,AX            ; out AH to underline register
  152.  
  153.  
  154.     Jmp     Short Finis
  155.  
  156. Norm_Pal:
  157.  
  158.     Assume  ES:@code
  159.  
  160.     Mov     DX, OFFSET Norm_Table
  161.     Mov     AX,1002h         ; reload Palette with table at ES:DX
  162.     Int     10h              ; table is 17 bytes long
  163.                  ; turn off underlining
  164.     Xor     BX,BX            ; set BX to 0
  165.     Mov     ES,BX            ; set ES to 0
  166.  
  167.     Assume  ES:Nothing
  168.  
  169.     Mov     AH,ES:[0485h]    ; read character height
  170.     Mov     DX,03B4h         ; load CRTC port address for mono display
  171.     Mov     AL,14h           ; underline location address register
  172.     Out     DX,AX            ; out AH to underline register
  173.  
  174. Finis:
  175.     Assume  DS:@data, ES:Nothing
  176.     Pop    BP
  177.     Ret
  178. EGAMONO    ENDP
  179. END
  180.